package stub.datasvStub;

import po.CouStuScoListPO;
import po.StuCouScoListPO;
import po.TeaCouListPO;
import resultmessage.CourseQueryRM;
import datasv.courseQuery_datasv.CourseQueryDatasv;

public class CourseQueryDatasvStub implements CourseQueryDatasv {
	CouStuScoListPO cscl;
	StuCouScoListPO	scsl;
	TeaCouListPO	tcl;
	public CourseQueryDatasvStub(CouStuScoListPO cscl, StuCouScoListPO scsl,
			TeaCouListPO tcl) {
		super();
		this.cscl = cscl;
		this.scsl = scsl;
		this.tcl = tcl;
	}
	@Override
	public CouStuScoListPO getAllStuOfCou(String courseID) {
		// TODO Auto-generated method stub
		if(courseID.equals(cscl.getCourseID())){
			return cscl;
		}
		return null;
	}

	@Override
	public StuCouScoListPO getAllCouOfStu(String studentID) {
		// TODO Auto-generated method stub
		if(studentID.equals(scsl.getStudentID())){
			return scsl;
		}
		return null;
	}

	@Override
	public TeaCouListPO getAllCouOfTea(String teacherID) {
		// TODO Auto-generated method stub
		if(teacherID.equals(tcl.getTeacherID())){
			return tcl;
		}
		return null;
	}

	@Override
	public CourseQueryRM deleteStuOfCou(String courseID, String studentID) {
		// TODO Auto-generated method stub
		if(!cscl.getCourseID().equals(courseID)){
			return CourseQueryRM.COURSEID_NOT_EXIST;
		}
		if(!cscl.getStudentIDScoreList().keySet().contains(studentID)){
			return CourseQueryRM.STUDENT_NOT_EXIST;
		}
		return CourseQueryRM.SUCCESS;
	}

	@Override
	public CourseQueryRM deleteCouOfStu(String courseID, String studentID) {
		// TODO Auto-generated method stub
		if(!scsl.getStudentID().equals(studentID)){
			return CourseQueryRM.STUDENT_NOT_EXIST;
		}
		if(!scsl.getCourseIDScoreList().keySet().contains(courseID)){
				return CourseQueryRM.COURSEID_NOT_EXIST;
		}
		return CourseQueryRM.SUCCESS;
	}

	@Override
	public CourseQueryRM addStuOfCou(String courseID, String studentID) {
		// TODO Auto-generated method stub
		if(!cscl.getCourseID().equals(courseID) ){
			return CourseQueryRM.COURSEID_NOT_EXIST;
		}
		if(cscl.getStudentIDScoreList().keySet().contains(studentID)){
			return CourseQueryRM.STUDENT_EXIST;
		}
		return CourseQueryRM.SUCCESS;
	}

	@Override
	public CourseQueryRM addCouOfStu(String courseID, String studentID) {
		// TODO Auto-generated method stub
		if(!scsl.getStudentID().equals(studentID)){
			return CourseQueryRM.STUDENT_NOT_EXIST;
		}
		if(scsl.getCourseIDScoreList().keySet().contains(courseID)){
				return CourseQueryRM.COURSEID_EXIST;
		}
		return CourseQueryRM.SUCCESS;
	}

	@Override
	public CourseQueryRM updateStuOfCou(String courseID, String studentID,
			int score) {
		// TODO Auto-generated method stub
		if(!cscl.getCourseID().equals(courseID) ){
			return CourseQueryRM.COURSEID_NOT_EXIST;
		}
		if(!cscl.getStudentIDScoreList().keySet().contains(studentID)){
			return CourseQueryRM.STUDENT_NOT_EXIST;
		}
		return CourseQueryRM.SUCCESS;
	}

	@Override
	public CourseQueryRM updateCouOfStu(String courseID, String studentID,
			int score) {
		// TODO Auto-generated method stub
		if(!scsl.getStudentID().equals(studentID)){
			return CourseQueryRM.STUDENT_NOT_EXIST;
		}
		if(!scsl.getCourseIDScoreList().keySet().contains(courseID)){
				return CourseQueryRM.COURSEID_NOT_EXIST;
		}
		return CourseQueryRM.SUCCESS;
	}

	@Override
	public CourseQueryRM addCouOfTea(String courseID, String teacherID) {
		// TODO Auto-generated method stub
		if(!tcl.getTeacherID().equals(teacherID)){
			return CourseQueryRM.STUDENT_NOT_EXIST;
		}
		if(tcl.getCourseIDList().contains(courseID)){
				return CourseQueryRM.COURSEID_EXIST;
		}
		return CourseQueryRM.SUCCESS;
	}

	@Override
	public CourseQueryRM deleteCouOfTea(String courseID, String teacherID) {
		// TODO Auto-generated method stub
		if(!tcl.getTeacherID().equals(teacherID)){
			return CourseQueryRM.STUDENT_NOT_EXIST;
		}
		if(!tcl.getCourseIDList().contains(courseID)){
				return CourseQueryRM.COURSEID_NOT_EXIST;
		}
		return CourseQueryRM.SUCCESS;
	}

}
